package com.community.comsys.service.impl;

import java.util.List;
import com.community.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.community.comsys.mapper.StorageRoomMapper;
import com.community.comsys.domain.StorageRoom;
import com.community.comsys.service.IStorageRoomService;

/**
 * 储藏室管理Service业务层处理
 * 
 * @author 潇东
 * @date 2025-10-27
 */
@Service
public class StorageRoomServiceImpl implements IStorageRoomService 
{
    @Autowired
    private StorageRoomMapper storageRoomMapper;

    /**
     * 查询储藏室管理
     * 
     * @param storageRoomId 储藏室管理主键
     * @return 储藏室管理
     */
    @Override
    public StorageRoom selectStorageRoomByStorageRoomId(Long storageRoomId)
    {
        return storageRoomMapper.selectStorageRoomByStorageRoomId(storageRoomId);
    }

    /**
     * 查询储藏室管理列表
     * 
     * @param storageRoom 储藏室管理
     * @return 储藏室管理
     */
    @Override
    public List<StorageRoom> selectStorageRoomList(StorageRoom storageRoom)
    {
        return storageRoomMapper.selectStorageRoomList(storageRoom);
    }

    /**
     * 新增储藏室管理
     * 
     * @param storageRoom 储藏室管理
     * @return 结果
     */
    @Override
    public int insertStorageRoom(StorageRoom storageRoom)
    {
        storageRoom.setCreateTime(DateUtils.getNowDate());
        return storageRoomMapper.insertStorageRoom(storageRoom);
    }

    /**
     * 修改储藏室管理
     * 
     * @param storageRoom 储藏室管理
     * @return 结果
     */
    @Override
    public int updateStorageRoom(StorageRoom storageRoom)
    {
        storageRoom.setUpdateTime(DateUtils.getNowDate());
        return storageRoomMapper.updateStorageRoom(storageRoom);
    }

    /**
     * 批量删除储藏室管理
     * 
     * @param storageRoomIds 需要删除的储藏室管理主键
     * @return 结果
     */
    @Override
    public int deleteStorageRoomByStorageRoomIds(Long[] storageRoomIds)
    {
        return storageRoomMapper.deleteStorageRoomByStorageRoomIds(storageRoomIds);
    }

    /**
     * 删除储藏室管理信息
     * 
     * @param storageRoomId 储藏室管理主键
     * @return 结果
     */
    @Override
    public int deleteStorageRoomByStorageRoomId(Long storageRoomId)
    {
        return storageRoomMapper.deleteStorageRoomByStorageRoomId(storageRoomId);
    }

    /**
     * 导入储物室列表
     * @param roomsList
     * @return
     */
    @Override
    public int importHouseList(List<StorageRoom> roomsList) {
        roomsList.stream().forEach(storageRoom -> {
            storageRoom.setCreateTime(DateUtils.getNowDate());
            storageRoomMapper.insertStorageRoom(storageRoom);
        });

        return roomsList.size();
    }
}
